from django.db import models

# Create your models here.
"""图书模型类"""
class BookInfo(models.Model):
    #标题
    btitle = models.CharField(max_length=20,verbose_name='标题')
    #发布日期
    bpub_date = models.DateField(verbose_name='发布日期')
    # 阅读量
    bread = models.IntegerField(default=0,verbose_name='阅读量')
    # 评论量
    bcomment = models.IntegerField(default=0,verbose_name='评论量')
    # 删除标记
    is_delete = models.BooleanField(default=False,verbose_name='删除标记')

    #改名
    class Meta(object):
        db_table = 'tb_books'
        verbose_name = '图书'
        verbose_name_plural = verbose_name

    #打印名称
    def __str__(self):
        return self.btitle

"""角色模型类"""
class HerInfo(models.Model):
    #角色名称
    hname = models.CharField(max_length=20,verbose_name='名称')
    #角色性别
    GENDER_CHOIES = (
        (0,'男'),
        (1,'女')
    )
    hgender = models.IntegerField(default=0,verbose_name='性别',choices=GENDER_CHOIES)
    # 角色备注
    hcomment = models.CharField(max_length=200,verbose_name='备注')
    #删除标记
    is_delete = models.BooleanField(default=False,verbose_name='删除标记')
    #关联属性，所属图书外键
    hbook = models.ForeignKey('BookInfo',on_delete=models.CASCADE,verbose_name='所属图书')


    #改名
    class Meta(object):
        db_table = 'tb_heros'
        verbose_name = '英雄'
        verbose_name_plural = verbose_name
    #打印名称
    def __str__(self):
        return self.hname



